-
Notifications
You must be signed in to change notification settings - Fork 9
Issue 11 - layout/design_layout_snackbar_include: Error inflating class android.widget.Button #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Updated the `Microsoft.Maui.Controls` package version from a variable reference `$(MauiVersion)` to a specific version `9.0.82` in both the `Maui.Android.InAppUpdates.SampleApp.csproj` and `Maui.Android.InAppUpdates.csproj` files.
Updated `Microsoft.Extensions.Logging.Debug` to version `9.0.7` in `Maui.Android.InAppUpdates.SampleApp.csproj`. In `Maui.Android.InAppUpdates.csproj`, incremented versions of several Xamarin.AndroidX and Google Play App Update packages to: - `Xamarin.AndroidX.Activity.Ktx` to `1.10.1.2` - `Xamarin.AndroidX.Collection.Ktx` to `1.5.0.2` - `Xamarin.AndroidX.Fragment.Ktx` to `1.8.8` - `Xamarin.Google.Android.Play.App.Update.Ktx` to `2.1.0.15`
- Modified `ShowShortToast` to include null checks and exception handling. - Refactored `ShowSnackbar` to add fallback to toast and improved error handling for theme-related exceptions. - Introduced `FallbackToToastWithAction` and `HandleSnackbarFailure` for better organization and readability. - Added `IsThemeRelated` method to identify theme-related exceptions.
- Added a new "NuGet" PropertyGroup in `Maui.Android.InAppUpdates.csproj` for package ID, description, and tags. - Replaced hardcoded `Microsoft.Maui.Controls` version with variable `$(MauiVersion)` for improved version management. - Updated ItemGroup for package references while retaining AndroidX library references.
Modified the parameter documentation for the `ShowSnackbar` method. Removed the note about the `clickHandler` parameter being nullable and replaced it with a simpler description of its purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses theme-related crashes in the Android in-app updates library by adding comprehensive error handling and fallback mechanisms to the UI components. The changes focus on resolving the "Error inflating class android.widget.Button" issue mentioned in the title.
- Enhanced error handling in
ShowShortToastwith null checks and exception catching - Refactored
ShowSnackbarwith theme-specific exception handling and toast fallback - Updated Android package dependencies to newer versions
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| DefaultUserInterface.cs | Added comprehensive error handling, theme-related exception detection, and fallback mechanisms for toast and snackbar operations |
| Maui.Android.InAppUpdates.csproj | Updated AndroidX and Google Play package versions to newer releases |
| Maui.Android.InAppUpdates.SampleApp.csproj | Updated Microsoft.Maui.Controls and logging package versions |
src/libs/Maui.Android.InAppUpdates/Platforms/Android/DefaultUserInterface.cs
Show resolved
Hide resolved
src/libs/Maui.Android.InAppUpdates/Platforms/Android/DefaultUserInterface.cs
Show resolved
Hide resolved
src/libs/Maui.Android.InAppUpdates/Platforms/Android/DefaultUserInterface.cs
Show resolved
Hide resolved
Replaced hardcoded version number for the Microsoft.Maui.Controls package in the project file `Maui.Android.InAppUpdates.SampleApp.csproj` with a variable `$(MauiVersion)` for improved version management.
|
@HavenDV github Copilot concerns are probably valid but with the absence of the ability to actually invoke the |
|
I think we use clickHandler only in one place: in this case, if we have issues with UI, it will restart app - so should be ok for users |
*Refactor DefaultUserInterface.cs for Better Error Handling and Code Quality & Prevent Theme-related crashes
The PR essentially says: "I prefer to show a Snackbar, but if your app's theme prevents it, I will gracefully fall back to a Toast and ensure the intended action still takes place, thus maximizing compatibility.